<template>
	<view class="uni_box home">
		<navbar title='我的报名'>
			<!-- <view class="hright" slot="right">
				<text>刷新</text>
			</view> -->
		</navbar>
		<u-sticky offset-top="0" h5-nav-height="0">
			<view class="wrap">
				<u-tabs :list="tablist" :is-scroll="false" :current="current" @change="tabchange" active-color="#2291FC" inactive-color="#666666"></u-tabs>
			</view>
		</u-sticky>
		<view class="content">

			<view class="blist">
				<view class="bitem" v-for="(item,index) in list" :key="index" @click="getdteail(item)">
					<image class="tuimg" :src="item.image"></image>
					<view class="turight">
						<text class="tname">{{item.title}}</text>
						<view class="tbot">
							<text class="baoname">报名数量： <text class="baonum">{{ item.count }}</text></text>
							<view class="cha">
								<text>查看 ></text>
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" @loadmore="loadmore" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				tablist:[
					{
						name: '悬赏'
					},
					{
						name: '名片'
					},
				],
				current:0,
			}
		},
		onLoad() {
			this.getList()
		},
		onShow() {
		},
		onReachBottom: function () {
			this.loadmore();
		},
		methods: {
			tabchange(e){
				this.current = e
				this.getClear()
			},
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			},
			async getList(){//列表数据
				if(this.current == 0){
					let res = await this.$u.api.getBaoMingList({
						// limit:this.limit,
						page:this.page
					});
					this.last_page = res.lastpage;
					let list = res.list;
					this.list = this.page == 1 ? list : [...this.list, ...list];	
					if(this.page >= this.last_page){
						this.status = 'nomore';
					}
				}else if(this.current == 1){
					let res = await this.$u.api.cardgetBaoMingList({
						// limit:this.limit,
						page:this.page
					});
					this.last_page = res.lastpage;
					let list = res.list;
					this.list = this.page == 1 ? list : [...this.list, ...list];	
					if(this.page >= this.last_page){
						this.status = 'nomore';
					}
				}
				
				
				
			},
			loadmore() {
				let page = this.page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			getdteail(item){
				if(this.current == 0){
					this.navrouter("/pages_subject/twoPage/MyBaoming?id="+item.id+'&leitype=1');
				}else if(this.current == 1){
					// apply_id
					this.navrouter("/pages_subject/twoPage/RenDetail?mid="+item.apply_id);
				}
				
				// this.navrouter("/pages/TPage/MyOrder?leitype=1"+'&bao_id='+item.id);
			},
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.content{
		min-height: 100vh;
		background-color: #f5f5f5;
		padding: 20rpx 30rpx;
		.blist{
			.bitem{
				background: #FFFFFF;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 20rpx;
				display: flex;
				flex-direction: row;


				.tuimg{
					width: 160rpx;
					margin-right: 20rpx;
					height: 160rpx;
					border-radius: 5rpx;
				}
				.turight{
					flex: 1;
					display: flex;
					flex-direction: column;
					padding: 10rpx 0;
					.tname{
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
					}
					.tbot{
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-top: auto;
						.baoname{
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 28rpx;
							color: #999999;
						}
						.baonum{
							color: #333;
						}
						.cha{
							margin-left: auto;
							display: flex;
							flex-direction: row;
							align-items: center;
							text{
								font-weight: 500;
								font-size: 24rpx;
								color: #999999;
							}
						}
					}
				}

			}
		}
	}
	
</style>
